<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            托入库
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">业务类型</div>
                    <div class="aui-list-item-input">
                        <select id="businessType" onchange="onChangeInBusiness()">
                        </select>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">子业务类型</div>
                    <div class="aui-list-item-input">
                        <select id="subBusinessType">
                        </select>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">仓库</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="workCenterCode" disabled="true">
                    </div>
                </div>
            </li>
            <!--   <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">仓库</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择/扫描 仓库" id="workCenterCode" value="" onclick="getIdSelector();" />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCenter()"></i>
                </div>
            </li> -->
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">库位</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择/扫描 库位" id="workCellCode" value=""
                            onclick="getIdSelector();" />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCell()"></i>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">托号</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请扫描托号" id="traynum" value="" onclick="getIdSelector();">
                    </div>
                </div>
            </li>
            <!-- <li class="aui-list-item" style="display:none">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">条码</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="tm">
                    </div>
                </div>
            </li>
            <li class="aui-list-item" style="display:none">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">条码ID</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="tmID">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">物料号</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="mrlCode" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">批次号</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="lotCode" disabled="true">
                    </div>
                </div>
            </li>
          -->
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">托容量</div>
                    <div class="aui-list-item-input">
                        <input type="number" id="qty" disabled="true">
                    </div>
                </div>
            </li>
        </ul>
        <p></p>
        <p></p>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="save()">保存</div>
        <div style="background-color:white; height: 100%;width: 100%;margin-top:2%;margin-bottom:50px;">
            <table class="table" style='width:100%;' id="table">
                <thead>
                    <tr
                        style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-size: 8px;font-weight: bold;">
                        <td algin='center'>箱号</td>
                        <td algin='center'>物料号</td>
                        <td algin='center'>数量</td>
                        <td algin='center'>批次</td>
                        <td algin='center'>仓库</td>
                        <td algin='center'>库位</td>
                        <td algin='center'>入库结果</td>
                        <td algin='center'>入库信息</td>
                    </tr>
                </thead>
                <tbody id="tbodyHtml">
                </tbody>
            </table>
        </div>
    </div>
    <footer class="aui-bar aui-bar-tab" id="footer">
        <div class="aui-bar-tab-item" tapmode id="scan" onclick="doScan()">
            <i class="aui-iconfont aui-icon-scan aui-text-epblue" style="font-size: 1.8rem"></i>
        </div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var workCenterGid = ""; //仓库GID
    var workCenterCode = ""; //仓库编码
    var workCenterName = ""; //仓库名称
    var workCellGid = ""; //库位GID
    var workCellCode = ""; //库位编码
    var workCellName = ""; //库位名称

    var scanRule = ""; //条码解析规则
    var code; //菜单路由参数
    var codesub; //菜单路由参数
    //初始化查询仓库下拉框
    apiready = function () {
        $("#workCenterCode").focus();
        idSelector = "workCenterCode";
        var query = api.pageParam.query;
        code = query.code
        codesub = query.codesub
        var businessTypeDisable = query.typeDisable;//是否禁用业务类型和子业务类型
        if (businessTypeDisable != undefined && businessTypeDisable != null && businessTypeDisable == "Y") {
            $("#businessType").attr('disabled', true);
            $("#subBusinessType").attr('disabled', true);
        }
        //查询条码解析规则
        // initScanRule();
        //查询业务类型下拉框
        doSearchBusinessType();
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }
    //
    // //查询扫描规则
    // function initScanRule() {
    //     var serverUrl = localStorage.getItem('serverUrl');
    //     var un = localStorage.getItem("un");
    //     var url = serverUrl + "/app/getTmScanRule";
    //     var data = {
    //         values: {
    //             un: un
    //         }
    //     };
    //     api.ajax({
    //         url: url,
    //         method: 'post',
    //         dataType: 'json',
    //         timeout: 300,
    //         returnAll: false,
    //         data: data
    //     }, function(ret, err) {
    //         if (ret) {
    //             var data = JSON.stringify(ret);
    //             var myobj = eval("(" + data + ")");
    //             if (myobj.code == '0') {
    //                 scanRule = myobj.scanRule
    //             } else {
    //                 api.toast({
    //                     msg: myobj.message,
    //                     duration: 3000
    //                 });
    //             }
    //         }
    //     });
    // }

    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {
            //alert(ret);扫码的结果都是编码
            //1：仓库
            /*    if (idSelector == 'workCenterCode') {
   
                   $("#workCenterCode").val(ret);
                   //查询仓库
                   getWorkCenter(ret, idSelector);
   
                   //2:库位
               } else */
            if (idSelector == 'workCellCode') {

                $("#workCellCode").val(ret);
                //查询库位
                getWorkCell(ret, idSelector);

                //扫描条码
            } else if (idSelector == 'traynum') {
                //查询托下的箱信息显示
                $("#traynum").val(ret);
                getBoxInfoByTray(ret, 1);
            }
        });
    }
    //查询托下的箱信息展示 flag=1 为初始扫描托号获取箱信息，不显示库转结果、库转信息列，
    //flag=2 为库转保存后返回显示，需要显示库转结果、库转信息列
    function getBoxInfoByTray(traynum, flag, code, codeS) {
        if (traynum == undefined || traynum == null || traynum == "") {
            $("#qty").val("");
            $api.html($api.byId("tbodyHtml"), "");
        } else {
            var un = localStorage.getItem('un');
            var serverUrl = localStorage.getItem('serverUrl');
            var url = serverUrl + "/app/getBoxInfoByTray";
            var params = new Object();
            params.url = url;
            params.dataType = 'json';
            params.method = 'post';
            var data = {
                values: {
                    traynum: traynum,
                    un: un
                }
            };
            api.ajax({
                url: url,
                method: 'post',
                dataType: 'json',
                timeout: 300,
                returnAll: false,
                data: data
            }, function (ret, err) {
                if (ret) {
                    var data = JSON.stringify(ret);
                    var myobj = eval("(" + data + ")");
                    //成功
                    if (myobj.code == '0') {
                        var list = myobj.list;
                        var html = "";
                        $("#qty").val(list.length);
                        //遍历
                        for (var i = 0; i < list.length; i++) {
                            html += "<tr style='text-align: center;background-color: #F5F5F5;color: black;font-size: 8px;'>";
                            html += "<td name='ext01'>" + list[i].ext01 + "</td>";
                            html += "<td name='mrlCode'>" + list[i].mrlCode + "</td>";
                            html += "<td name='ext02'>" + list[i].ext02 + "</td>";
                            html += "<td name='ext05'>" + list[i].ext05 + "</td>";
                            html += "<td name='workCenterName'>" + (list[i].workCenterGid == null ? "" : list[i].workCenterGid) + "</td>";
                            html += "<td name='workCellName'>" + (list[i].workCellGid == null ? "" : list[i].workCellGid) + "</td>";
                            if (flag == 2) {
                                if (list[i].ext06 == 'S' || list[i].ext06 == '' || list[i].ext06 == null) {
                                    if (codeS == '1') {
                                        html += "<td name='ext06'></td>";
                                        html += "<td name='ext07'></td>";
                                    }
                                    else if ((list[i].ext06 == '' || list[i].ext06 == null) && code == '1') {
                                        html += "<td name='ext06' style='background-color:red;'>E</td>";
                                        html += "<td name='ext07' style='background-color:red;'>入库失败</td>";
                                    } else if (code == '2') {
                                        html += "<td name='ext06'></td>";
                                        html += "<td name='ext07'></td>";
                                    } else {
                                        html += "<td name='ext06' style='background-color:green;'>S</td>";
                                        html += "<td name='ext07' style='background-color:green;'>入库成功</td>";
                                    }
                                } else if (list[i].ext06 == 'E') {
                                    html += "<td name='ext06' style='background-color:red;'>" + list[i].ext06 + "</td>";
                                    html += "<td name='ext07' style='background-color:red;'>" + list[i].ext07 + "</td>";
                                }
                            }
                            html += "</tr>";
                        }

                        $api.html($api.byId("tbodyHtml"), html);
                        $("#traynum").focus();
                        $("#traynum").select();
                        idSelector = "traynum";
                    } else if (myobj.code == '1') {
                        api.toast({
                            msg: myobj.message,
                            duration: 3000
                        });
                        $api.html($api.byId("tbodyHtml"), "");
                        $("#traynum").focus();
                        $("#traynum").select();
                        idSelector = "traynum";
                    }
                }
            })
        }



    }

    /*   //1：仓库扫描校验
      function getWorkCenter(code, inputId) {
          var serverUrl = localStorage.getItem('serverUrl');
          var url = serverUrl + "/app/getWorkCenter";
          var data = {
              values: { ////以表单方式提交参数（JSON对象）
                  workCenterCode: code,
                  mrlCode: "",
                  lotCode: "",
                  qty: ""
              }
          };
          api.ajax({
              url: url,
              method: 'post',
              dataType: 'json',
              timeout: 300,
              returnAll: false,
              data: data
          }, function(ret, err) {
              if (ret) {
                  var data = JSON.stringify(ret);
                  var myobj = eval("(" + data + ")");
                  //成功
                  if (myobj.code == '0') {
                      var list = eval(myobj.list);
                      workCenterGid = list[0].workCenterGid;
                      workCenterCode = list[0].workCenterCode;
                      workCenterName = list[0].workCenterName;
                      document.getElementById(inputId).value = list[0].workCenterCode + ":" + list[0].workCenterName;
                      $("#workCellCode").focus();
                      idSelector = "workCellCode";
  
                  } else {
                      api.toast({
                          msg: myobj.message,
                          duration: 3000
                      });
                      $("#workCenterCode").focus();
                      $("#workCenterCode").select();
                  }
              }
          });
      }
   */
    /*  //2：选中仓库
     function goSelectWorkCenter() {
         api.openWin({
             name: 'uwmSelectWorkCenter',
             url: 'uwmSelectWorkCenter.html',
             pageParam: {
                 flag: "in",
                 name: "uwmInOfStockByTray",
                 mrlCode: "",
                 lotCode: "",
                 qty: ""
             }
         });
     }
 
     //仓库选择后回调函数
     function setWorkCenter(id, code, name) {
         workCenterGid = id;
         workCenterCode = code;
         workCenterName = name;
         //$("#workCenterCode").attr("value",code+":"+name);
         document.getElementById('workCenterCode').value = code + ":" + name;
         $("#workCellCode").focus();
         idSelector = "workCellCode";
     } */

    /*    //3；PDA自带扫描回车事件
       $("#workCenterCode").on('keypress', function(e) { //#keyword为input文本框
           var keycode = e.keyCode;
           var sm = $(this).val();
           if (keycode == '13') {
               //仓库编码
               $("#workCenterCode").val(sm);
               // console.log("扫描回车事件：" + sm);
               //校验改箱码是否存在
               getWorkCenter(sm, "workCenterCode");
           }
       });
    */
    //5:库位扫描校验
    function getWorkCell(code, inputId) {
        //扫库位前先扫仓库
        /*   if (inputId == "workCellCode") {
              if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
                  api.toast({
                      msg: "请先选择/扫描 仓库",
                      duration: 3000
                  });
                  $("#workCellCode").val("");
                  workCellCode = "";
                  workCellGid = "";
                  workCellName = "";
                  return;
              }
          } */
        var un = localStorage.getItem("un");
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCell";
        var data = {
            values: {
                flag: "in_rk", //库内库间标识（out_kn库内  out_kj库间,in_rk入库出库）
                workCenterGid: workCenterGid, //仓库GID
                workCellCode: code, //库位编码
                relWorkCellGid: "", //调入库位
                tm: "",
                workCellFlag: "", //原库位调入库位flag
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    workCellGid = list[0].workCellGid;
                    workCellCode = list[0].workCellCode;
                    workCellName = list[0].workCellName;
                    document.getElementById(inputId).value = list[0].workCellCode + ":" + list[0].workCellName;
                    $("#boxnum").focus();
                    idSelector = "boxnum";
                    backtype(workCellGid)
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#workCellCode").focus();
                    $("#workCellCode").select();
                }
            }
        });

    }

    //6：选择库位
    function goSelectWorkCell() {
        var tm = $("#tm").val();
        /*     //仓库非空校验
            if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
                api.toast({
                    msg: "请先选择/扫描 仓库",
                    duration: 3000
                });
                return;
            } */

        api.openWin({
            name: 'uwmSelectWorkCell',
            url: 'uwmSelectWorkCell.html',
            pageParam: {
                flag: "in_rk",
                name: "uwmInOfStockByTray",
                tm: tm,
                workCenterGid: workCenterGid,
                relWorkCellGid: "",
                workCellFlag: ""
            }
        });

    }


    function backtype(workCellGid) {
        console.log(workCellGid);
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getworkWay";
        var data = {
            values: {
                workCellGid: workCellGid, //库位id
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        },
            function (ret, err) {
                if (ret) {
                    var data = JSON.stringify(ret);
                    console.log(data);
                    var myobj = eval("(" + data + ")");

                    console.log(myobj);
                    //成功
                    if (myobj.code == '0') {
                        console.log(myobj.centerCode);
                        console.log(myobj.centerName);
                        $("#workCenterCode").val(myobj.centerCode + ":" + myobj.centerName);

                        console.log($("#workCenterCode").val());

                    } else if (myobj.code == "1") {

                        api.toast({
                            msg: myobj.message,
                            duration: 3000
                        });
                    }
                }
            });
    }
    //库位选择后回调函数
    function setWorkCell(id, code, name) {

        workCellGid = id;
        workCellCode = code;
        workCellName = name;

        document.getElementById('workCellCode').value = code + ":" + name;

        $("#boxnum").focus();
        var e = "boxnum";
        idSelector = e;

        backtype(workCellGid)
    }

    //7；PDA自带扫描回车事件-库位
    $("#workCellCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {
            //仓库编码
            $("#workCellCode").val(sm);
            //校验改箱码是否存在
            getWorkCell(sm, "workCellCode");
        }
    });

    //业务类型下拉框
    function doSearchBusinessType() {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getBusinessType";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                type: 'IN',
                un:un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var map = eval("(" + data + ")");
                var list = eval(map.list);
                var html = "<option value=''>--请选择--</option>";
                for (var i = 0; i < list.length; i++) {
                    html += "<option value='" + list[i].code + "'>" + list[i].name + "</option>";
                }
                $api.html($api.byId("businessType"), html);
                $("#businessType").val(code);
                onChangeInBusiness();
            }
        });
    }

    //业务类型下拉框值改变
    function onChangeInBusiness() {
        var businessType = $("#businessType").val();
        //源仓库不为空，查询库位下拉框
        if (businessType != "" && businessType != null && businessType != undefined) {
            var un = localStorage.getItem('un');
            var serverUrl = localStorage.getItem('serverUrl');
            var url = serverUrl + "/app/getSubBusinessType";
            var data = {
                values: { ////以表单方式提交参数（JSON对象）
                    type: 'IN',
                    businessType: businessType,
                    un:un
                }
            };
            api.ajax({
                url: url,
                method: 'post',
                dataType: 'json',
                timeout: 300,
                returnAll: false,
                data: data
            }, function (ret, err) {
                if (ret) {
                    var data = JSON.stringify(ret);
                    var map = eval("(" + data + ")");
                    var list = eval(map.list);
                    var html = "<option value=''>--请选择--</option>";
                    var idSub = "";
                    for (var i = 0; i < list.length; i++) {
                        html += "<option value='" + list[i].sysid + "'>" + list[i].name + "</option>";
                        if (codesub == list[i].code) {
                            idSub = list[i].sysid;
                            y.innerHTML = list[i].name;
                        }
                    }
                    $api.html($api.byId("subBusinessType"), html);
                    $("#subBusinessType").val(idSub);
                }
            });
        } else {
            $api.html($api.byId("subBusinessType"), "");
        }


    }

    //保存按钮
    function save() {
        //业务类型
        var businessType = $("#businessType").val();
        //子业务类型
        var subBusinessType = $("#subBusinessType").val();
        //物料号
        // var mrlCode = $("#mrlCode").val();
        //批次号
        // var lotCode = $("#lotCode").val();
        //数量
        var qty = $("#qty").val();
        //条码
        // var tm = $("#tm").val();
        //托号
        var traynum = $("#traynum").val();
        //条码ID
        // var tmID = $("#tmID").val();

        //业务类型非空校验
        if (businessType == "" || businessType == null || businessType == undefined) {
            api.toast({
                msg: '请选择业务类型',
                duration: 3000
            });
            return;
        }

        /*   //仓库非空校验
          if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
              api.toast({
                  msg: '请选择/扫描仓库',
                  duration: 3000
              });
              return;
          } */

        //库位非空校验
        if (workCellGid == "" || workCellGid == null || workCellGid == undefined) {
            api.toast({
                msg: '请选择/扫描库位',
                duration: 3000
            });
            return;
        }

        //箱码非空校验
        if (traynum == "" || traynum == null || traynum == undefined) {
            api.toast({
                msg: '托号不能为空',
                duration: 3000
            });
            return;
        }

        //物料非空校验
        // if (mrlCode == "" || mrlCode == null || mrlCode == undefined) {
        //     api.toast({
        //         msg: '物料号不能为空',
        //         duration: 3000
        //     });
        //     return;
        // }

        //批次号非空校验
        // if (lotCode == "" || lotCode == null || lotCode == undefined) {
        //     api.toast({
        //         msg: '批次号不能为空',
        //         duration: 3000
        //     });
        //     return;
        // }

        //数量非空校验
        if (qty == "" || qty == null || qty == undefined) {
            api.toast({
                msg: '请输入入库数量',
                duration: 3000
            });
            return;
        } else {
            if (parseFloat(qty) <= 0) {
                api.toast({
                    msg: '入库数量必须大于0',
                    duration: 3000
                });
                return;
            }
        }

        api.showProgress({
            title: '保存中...',
        });
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/uwmInOfStockByTraySave";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                businessType: businessType, //业务类型
                subBusinessType: subBusinessType, // 子业务类型
                workCenterGid: workCenterGid, //仓库id
                workCellGid: workCellGid, //库位编码
                traynum: traynum, //箱号
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.codeS == '1') {
                    $("#traynum").val("");
                    api.hideProgress();
                    $("#traynum").select();
                  
                    getBoxInfoByTray(traynum, 2, myobj.code, myobj.codeS);
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
                else if (myobj.code == '0') {

                    api.hideProgress();
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    getBoxInfoByTray(traynum, 2);

                    $("#traynum").focus();
                    idSelector = "traynum";
                    $("#message").html(myobj.message);
                } else if (myobj.code == '1') {
                    $("#traynum").val("");
                    api.hideProgress();
                    $("#traynum").select();
                    getBoxInfoByTray(traynum, 2, myobj.code);
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                } else {
                    $("#traynum").val("");
                    api.hideProgress();
                    $("#traynum").select();
                    getBoxInfoByTray(traynum, 2, myobj.code);
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }








    //箱号监听回车事件
    $("#traynum").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            if (tm != null && tm != "" && tm != undefined) {
                console.log(tm);
                $("#traynum").blur();
                // $("#traynum").select();
                getBoxInfoByTray(tm, 1);
            }

        }
    });

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>